/**
 * 获取热门书籍的列表
 */

const { Sequelize, Model } = require('sequelize')
const { sequelize } = require('@core/db.js')

class HotBook extends Model {
  static async getList () {
    const bookList = await HotBook.findAll({
      order: [
        ['index', 'DESC']
      ]
    })
    return bookList
  }
}

HotBook.init({
  index: Sequelize.INTEGER,
  title: Sequelize.STRING,
  author: Sequelize.STRING,
  image: Sequelize.STRING
}, {
  sequelize,
  tableName: 'hot_book'
})

module.exports = {
  HotBook
}